home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Sound / Amster / Source / include / thread.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-12-13  |  1.5 KB  |  77 lines

  1. /*
  2. ** Thread Header
  3. */
  4.  
  5. #include <sys/types.h>
  6.  
  7. #include <exec/ports.h>
  8. #include <exec/tasks.h>
  9.  
  10. #include "compiler.h"
  11.  
  12. #ifndef AMSTER_THREAD_H
  13. #define AMSTER_THREAD_H
  14.  
  15. extern u_long th_sigmask;
  16.  
  17. struct thread_struct;
  18.  
  19. typedef void (*thcb)(struct thread_struct *t, int com, APTR data);
  20.  
  21. typedef struct thmsg_struct
  22. {
  23.     struct Message header;
  24.     struct thread_struct *sender;
  25.     int com;
  26.     APTR data;
  27.     int isreply;
  28. } *thmsg, _thmsg;
  29.  
  30. typedef struct thread_struct
  31. {
  32.     struct thread_struct *next;
  33.     struct Task *task;
  34.     struct MsgPort *port;
  35.     struct MsgPort *mother;
  36.     struct Task *mother_task;
  37.     thcb handler;
  38.     APTR data;
  39.     _thmsg sm;
  40.     _thmsg em;
  41. } *thread, _thread;
  42.  
  43. enum thread_state {
  44.     THC_STARTUP = -1,
  45.     THC_EXIT = -2,
  46.     THC_FINISH = -3
  47. };
  48.  
  49.  
  50. extern int th_init(void);
  51. extern void th_exit(void);
  52.  
  53. extern thread th_spawn(thcb handler, char *name, void (*func)(void), int pri, APTR data);
  54. extern void th_message(thread t, int com, APTR data);
  55. extern void th_poll(void);
  56.  
  57. /* following functions are called from threads */
  58. extern thread thr_init(void);
  59. extern void thr_exit(thread t, int reason);
  60. extern void thr_message(thread t, int com, APTR data);
  61.  
  62.  
  63. #ifdef __MORPHOS__
  64. #define THREAD_DECL(x) struct EmulLibEntry x
  65. #define THREAD(x) \
  66.     static void x ## _gate(void); \
  67.     struct EmulLibEntry x = { \
  68.     TRAP_LIB, 0, (void (*)(void)) & x ## _gate }; \
  69.     static void x ## _gate(void)
  70. #else
  71. #define THREAD_DECL(x) void SAVEDS ASM x (void)
  72. #define THREAD(x) void SAVEDS ASM x (void)
  73. #endif
  74.  
  75.  
  76. #endif    /* AMSTER_THREAD_H */
  77.